from rest_framework import serializers

from .models import Area

class AreasSerializer(serializers.ModelSerializer):
    """输出Area模型类中的数据"""
    class Meta:
        # 指定父集查询集的模型类
        model = Area
        # 指定输出的字段
        fields = ('id','name')

class SubsAreasSerializer(serializers.ModelSerializer):
    """输出Area模型类中的数据"""

    subs = AreasSerializer(many=True,read_only=True)

    class Meta:
        # 指定子集查询集的模型类
        model = Area
        # 指定输出的字段
        fields = ('id','name','subs')



